{extend name="public/base"}

{block name="x-body"}
  <div class="x-body">
    <div class="layui-row">
      <form class="layui-form layui-col-md12 x-so" method="get">
        <div class="layui-input-inline">
          <select name="cat_id">
            <option value="">全部文章</option>
            {volist name="article_cat" id="v"}
            <option value="{$v.id}" {$search_key.cat_id == $v.id ? 'selected' : ''}>{$v.name}</option>
            {/volist}
          </select>
        </div>
        <input type="text" name="title"  placeholder="请输入文章标题" autocomplete="off" class="layui-input" value="{$search_key.title}">
        <button class="layui-btn"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
      </form>
    </div>
    <xblock>
      <button class="layui-btn layui-btn-danger" onclick="delAll('{:url(\'article/article_del\')}')"><i class="layui-icon"></i>批量删除</button>
      <button class="layui-btn" onclick="x_admin_show('添加文章','{:url(\'article/article_form\')}')"><i class="layui-icon"></i>添加</button>
      <span class="x-right" style="line-height:40px">共有数据：{$list -> total()} 条</span>
    </xblock>
    <table class="layui-table layui-form">
      <thead>
        <tr>
          <th>
            <div class="layui-unselect header layui-form-checkbox" lay-skin="primary"><i class="layui-icon">&#xe605;</i></div>
          </th>
          <th>ID</th>
          <th>标题</th>
          <th>缩略图</th>
          <th>文章内容</th>
          <th>作者</th>
          <th>作者邮箱</th>
          <th>发布时间</th>
          <th>所属分类</th>
          <th width="50">显示</th>
          <th>操作</th>
      </thead>
      <tbody>
        {volist name="list" id="v"}
          <tr>
            <td>
              <div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id='{$v.id}'><i class="layui-icon">&#xe605;</i></div>
            </td>
            <td>{$v.id}</td>
            <td>{$v.title}</td>
            <td>
              {if $v.thumbnail}
                <img src="{:config('imgRoute')}{$v.thumbnail}" alt="" width="50">
              {/if}
            </td>
            <td>
              {$v.desc|strip_tags|interceptStr=###, 40}
            </td>
            <td>{$v.author}</td>
            <td>{$v.author_email}</td>
            <td>{$v.add_time|date='Y-m-d H:i:s'}</td>
            <td>{$v.cate_name}</td>
            <td>
              <input type="checkbox" name="switch" data-id="{$v.id}" data-status="{$v.is_show}" lay-text="是|否" {if $v.is_show == 1}checked=""{/if} lay-skin="switch">
            </td>
            <td class="td-manage">
              <a title="编辑"  onclick="x_admin_show('编辑文章', '{:url(\'article/article_form\', [\'id\' => $v.id])}')" href="javascript:;">
                <i class="layui-icon">&#xe642;</i>
              </a>
              <a title="删除" onclick="member_del(this,'{$v.id}', '{:url(\'article/article_del\')}')" href="javascript:;">
                <i class="layui-icon">&#xe640;</i>
              </a>
            </td>
          </tr>
        {/volist}
      </tbody>
    </table>
    <div class="page">
      <div>
        {$list -> render()|raw}
      </div>
    </div>

  </div>

<script>
  $(function (){
      /**
       * 更新状态
       */
      editStatus('{:url("articleStatus")}', 'is_show');
  })
</script>
{/block}